package com.tanhua.admin.controller;

import com.tanhua.admin.service.DashboardService;
import com.tanhua.model.admin.AnalysisSummaryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("/dashboard")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    /**
     *    101 新增 102 活跃用户 103 次日留存率
     * @param sd
     * @param ed
     * @param type
     * @return
     */
    @GetMapping("/users")
    public ResponseEntity getUsersCount(Long sd,Long ed,String type){
        switch (type) {
            case "101":
                Map<String, Object> usersCount = dashboardService.getUsersCount(sd, ed);
                return ResponseEntity.ok(usersCount);
            case "102":
                Map<String, Object> usersByType = dashboardService.getUsersByType(sd,ed);
                return ResponseEntity.ok(usersByType);
            case "103":
        }
        return  ResponseEntity.ok(null);
    }

    /**
     *  概要统计信息
     * @return
     */
    @GetMapping("/summary")
    public ResponseEntity getSummary(){
        AnalysisSummaryVo vo = dashboardService.getSummary();
        return ResponseEntity.ok(vo);
    }
}
